package lq;

import java.util.Scanner;

public class lq2005 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String nyr;
        int n,y,r,t;
        t=0;
        while (in.hasNext()){
           nyr = in.nextLine();
           String[] date = nyr.split("/");
           n = Integer.parseInt(date[0]);
            y = Integer.parseInt(date[1]);
            r = Integer.parseInt(date[2]);
            switch (y){
                case 1:t=r;break;
                case 2:t=r+31;break;
                case 3:t=r+59;break;
                case 4:t=r+90;break;
                case 5:t=r+120;break;
                case 6:t=r+151;break;
                case 7:t=r+181;break;
                case 8:t=r+212;break;
                case 9:t=r+243;break;
                case 10:t=r+273;break;
                case 11:t=r+304;break;
                case 12:t=r+334;break;
            }
            if (((n%400==0||(n%4==0&&n%100!=0))&&y>2)){
                System.out.println(t+1);
            }
            else{
                System.out.println(t);
            }
        }
    }
}
